/**
  ETFRoot project, Anyang Normal University && IMP-CAS
  \class ETFTimer
  \brief To represent any type of timing detectors
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2022-04-26
  \date 2022-04-26 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2022-04-26   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2022 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#include <cstring>
#include <TClonesArray.h>
#include "FairRootManager.h"
#include "ETFTimer.h"
#include "ETFPlaHit.h"

ETFTimer::ETFTimer(const char *name) : ETFDetector(name){}

ETFTimer::~ETFTimer(){
  if(fHits) delete fHits;
} // end the dtor

void ETFTimer::Register(){
  static FairRootManager *m = FairRootManager::Instance();
  if(fHits) m->Register(fHits->GetName(), "DetHits", fHits, true);
} // end member function Register

// initialize the detector
void ETFTimer::Initialize(){
  ETFDetector::Initialize();
  fHits->Clear();
} // end member function Initialize

void ETFTimer::Print(){
  ETFDetector::Print();
  for(auto p : *fHits) dynamic_cast<ETFPlaHit *>(p)->Print();
} // end member function Print
